Skip to content

feat: add coder_script_order resource for declarative script ordering#526

Closed
SasSwart wants to merge 1 commit into
mainfrom
sas/coder-script-order
Closed

feat: add coder_script_order resource for declarative script ordering#526
SasSwart wants to merge 1 commit into
mainfrom
sas/coder-script-order

Conversation

@SasSwart

Copy link
Copy Markdown
Contributor

Overview

Adds a coder_script_order managed resource that lets templates declare ordering dependencies between coder_script resources. Coder's provisioner and agent consume these declarations to gate script execution and record ordering in the sync-unit timeline (companion change in coder/coder#27160).

coder_script_order "startup" {
  rule {
    run   = [coder_script.install.id]
    after = [coder_script.clone.id]
    state = "completes" # or "starts"
  }
}

A rule declares that every script in run must wait for every script in after to reach state. Multiple coder_script_order blocks (and multiple rule blocks) are additive.

Details

  • provider/script_order.go: config-only managed resource, same pattern as coder_script/coder_env (Create sets a generated UUID id; Read/Delete are no-ops). Schema is a repeatable rule block:
    • run: list of strings, required.
    • after: list of strings, optional.
    • state: string, optional, default "completes", validated to completes/starts.
  • provider/provider.go: registers "coder_script_order" in ResourcesMap.
  • examples/resources/coder_script_order/resource.tf + generated docs/resources/script_order.md.
  • provider/script_order_test.go: unit tests covering rule parsing and empty-run handling.

rule is marked ForceNew because the resource has no update path (config-only, like coder_script); the SDK's InternalValidate requires it. make fmt and make gen (tfplugindocs) are clean.

Notes

The consuming coder/coder change keys off the coder_script_order type name in Terraform state, so it can be developed and unit-tested against state fixtures. End-to-end use requires this resource to be released and the provider version bumped in coder/coder.

Generated by Coder Agents on behalf of @SasSwart.

Add a config-only managed resource that lets templates declare ordering
constraints between coder_script resources on an agent. Each rule block
declares that the scripts in run must wait for the scripts in after to
reach a given lifecycle state (completes or starts). Multiple resources
are additive. Follows the coder_script/coder_env pattern: CreateContext
sets a uuid id and validates each rule, with Noop read/delete.

Includes docs, an example, and unit tests.

Generated by Coder Agents on behalf of @SasSwart.
@SasSwart SasSwart closed this Jul 15, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant